// nurse/list.js
var globalData = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //搜索相关
    title: "搜索",
    inputShowed: false,
    inputVal: "",

    typeId:null,
    nurses: [],
    appDomain: globalData.appDomain
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this = this;
    this.setData({
      typeId:options.id
    })
    let requestUrl = globalData.apiDomain + "/BookPatient?hglx=" + options.id;
  
    wx.request({
      url: requestUrl,
      method: "GET",
      success: function (res) {
        console.log(res.data);
        _this.setData({
          nurses: res.data.data
        })
      }
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    console.log("下拉");
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  /**
     * 搜索相关的方法
     */
  showInput: function () {
    this.setData({
      inputShowed: true
    });
  },
  hideInput: function () {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
    var _this = this;
    let requestUrl = globalData.apiDomain + "/BookPatient?hglx=" + this.data.typeId + "&name=";
   
    wx.request({
      url: requestUrl,
      method: "GET",
      success: function (res) {
        _this.setData({
          nurses: res.data.data
        })
      }
    })
  },
  clearInput: function () {
    this.setData({
      inputVal: ""
    });
    var _this = this;
    let requestUrl = globalData.apiDomain + "/BookPatient/GetByLxAndName?hglx=" + this.data.typeId + "&name=";
    console.log(requestUrl);
    wx.request({
      url: requestUrl,
      method: "GET",
      success: function (res) {
        _this.setData({
          nurses: res.data.data
        })
      }
    })
  },
  inputTyping: function (e) {
    this.setData({
      inputVal: e.detail.value
    });

    var _this = this;
    let requestUrl = globalData.apiDomain + "/BookPatient/GetByLxAndName?hglx=" + this.data.typeId+"&name="+e.detail.value;
    console.log(requestUrl);
    wx.request({
      url: requestUrl,
      method: "GET",
      success: function (res) {
        _this.setData({
          nurses: res.data.data
        })
      }
    })
  }
})